package datatypes;

import java.util.Vector;


public class ScenarioDescription {
	//Variables
	private String scenarioName = "none";
	private String subname = "none";
	private String description = "none";
	private int id = -1;

	private int rosterWidth = -1;
	private int rosterHeight = -1;
	
	private int range = -1;
	//Preconditions
	private Vector<HostDescription> hosts = null;
	
	//Order
	private Vector<ScenarioActionDescription> actions = null;

	public String getScenarioName() {
		return scenarioName;
	}

	public String getSubname() {
		return subname;
	}

	public String getDescription() {
		return description;
	}

	public Vector<HostDescription> getHosts() {
		return hosts;
	}

	public Vector<ScenarioActionDescription> getActions() {
		return actions;
	}
	
	public Vector<String> getActionNames(){
		Vector<String> tmp = new Vector<String>();
		for (int i=0; i < actions.size(); i++){
			tmp.add(actions.get(i).getUniqueName());
		}
		return tmp;
	}
	
	public Vector<String> getSimpleActionNames(){
		Vector<String> tmp = new Vector<String>();
		for (int i=0; i < actions.size(); i++){
			tmp.add(actions.get(i).getType());
		}
		return tmp;
		
	}
	public int getRosterWidth() {
		return rosterWidth;
	}

	public int getRosterHeight() {
		return rosterHeight;
	}

	public int getRange() {
		return range;
	}

	public void setID (int id){
		this.id = id;
	}
	
	public int getID (){
		return this.id;
	}
	public void setRange(int range) {
		this.range = range;
	}

	public void setRosterWidth(int rosterWidth) {
		this.rosterWidth = rosterWidth;
	}

	public void setRosterHeight(int rosterHeight) {
		this.rosterHeight = rosterHeight;
	}
	public void setScenarioName(String scenarioName) {
		this.scenarioName = scenarioName;
	}

	public void setSubname(String subname) {
		this.subname = subname;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setHosts(Vector<HostDescription> hosts) {
		this.hosts = hosts;
	}

	private void addHost(HostDescription host){
		if (hosts == null){
			hosts = new Vector<HostDescription>();
		}	
		this.hosts.add(host);
	}
	public void setActions(Vector<ScenarioActionDescription> actions) {
		this.actions = actions;
	}
	
	private void addAction(ScenarioActionDescription action){
		if (action != null){
			if (actions == null){
				actions = new Vector<ScenarioActionDescription>();
			}
			this.actions.add(action);
		}
	}

	private void addAction(String ActionName, String ActionType, String ActionLayer,String affectedObject){
		this.actions.add(new ScenarioActionDescription(ActionName, ActionType, ActionLayer,affectedObject));
	}
	
	public HostDescription getHostDescription (int hostID){
		for (int i=0; i < hosts.size(); i++){
			if (hosts.get(i).getHost().isEqual(hostID)){
				return hosts.get(i);
			}
		}
		return null;
	}
}
